;; **************************************************************************
;; * Symbolics Lisp Machine Keyboard to PS/2 Converter w/ Programmable Keys *
;; *                Copyright (c)2008 Stanislav Datskovskiy                 *
;; *                          stas@loper-os.org                             *
;; *                                                                        *
;; *                    See README for electric schematics                  *
;; *                                                                        *
;; *  This program is free software; you can redistribute it and/or modify  *
;; *  it under the terms of the GNU General Public License as published by  *
;; *  the Free Software Foundation; either version 3 of the License, or     *
;; *  (at your option) any later version.                                   *
;; *                                                                        *
;; *  This program is distributed in the hope that it will be useful,       *
;; *  but WITHOUT ANY WARRANTY; without even the implied warranty of        *
;; *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
;; *  GNU General Public License for more details.                          *
;; *                                                                        *
;; *  You should have received a copy of the GNU General Public License     *
;; *  along with this program.  If not, see <http://www.gnu.org/licenses/>. *
;; **************************************************************************

	list		p=16F84A		; define processor
	#include	<p16f84a.inc>		; processor-specific defs
	
	__CONFIG	_CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

	#include	"common.asm"		; common
	
	;; ******************************************************************
	;; Constants
	
	;; Speed Calibration
	#define		calibDelay	100	; Speed Calibration


	extern		Delay_second
	extern		sym_kbd_init
	extern		sym_kbd_test

	udata
tempvar		res	1

	code

	
;; Variables

;	cblock 0x0C
;		tempvar
;	endc	

	;; ******************************************************************
	ORG	0x000	; processor reset vector
	goto	main	; go to beginning of program
	ORG	0x004	; interrupt vector location
	;; Interrupt Service Routine
	;; 
	;; blah
	;; 
	retfie		; return from interrupt
	;; End of Interrupt Service Routine

	;; ******************************************************************
main
	;; Initialize CPU and Ports
	bcf	STATUS,RP0	; set bank zero
	clrf	PORTA		; clear port A
	clrf	PORTB		; clear port B
	bsf	STATUS,RP0	; set bank one
	bcf	INTCON,GIE	; disable interrupts
	movlw	trisPortA	; load port A tristates into W
	movwf	TRISA		; set port A tristates
	movlw	trisPortB	; load port B tristates into W
	movwf	TRISB		; set port B tristates
	bcf	STATUS,RP0	; set bank zero
	;; end of init

	;; Start of Program

	call	sym_kbd_init    ; initialize Symbolics keyboard

	call	sym_kbd_test

	;; Only a test
;; test
;; 	LED_ON	LED_SCROLL
;; 	call	Delay_second
;; 	LED_OFF	LED_SCROLL
;; 	call	Delay_second
;;  	LED_ON	LED_CAPS
;;  	call	Delay_second
;;  	LED_OFF	LED_CAPS
;;  	call	Delay_second
;;  	LED_ON	LED_NUM
;;  	call	Delay_second
;;  	LED_OFF	LED_NUM
;;  	call	Delay_second
;;  	LED_ON	LED_POWER
;;  	call	Delay_second
;;  	LED_OFF	LED_POWER
;;  	call	Delay_second
;; 	goto	test
	
	END
	
